<template>
  <div class="cabinet">
    <div class="cabinet-main">
      <ele-page
        v-loading="loading"
        :formConfig="searchConfig"
        ref="eleTable"
        :operateList="operateList"
        :column="column"
        :getList="getList"
        uniqueId="mesProcessTable"
        :otherParams="{'cabinetType':2}"
        @handleOperateEvent="handleOperateEvent"
      >
      </ele-page>
    </div>
  </div>
</template>

<script>
import { operateList, searchConfig, formDescDialogMinxin } from './config'
import { getList, exportUrl } from '@/api/cabinet/keyInventory/index.js'
// import url from '@/axios/url'
import { exportExcel } from '@/utils/judge'
// const { minioUrl } = url()
export default {
  name: 'keyInventory',
  mixins: [formDescDialogMinxin, searchConfig, operateList],
  data() {
    return {
      processCodeList: [],
      title: null,
      visible: false,
      isLoading: false,
      loading: false,
      formDataDialog: {},
      getList,
      // 列表页字段的绑定配置
      column: [
        // {
        //   type: 'selection',
        //   fixed: 'left'
        // },
        {
          type: 'index',
          label: $i18n.t('common.order'),
          width: 60,
          fixed: 'left'
        },
        {
          prop: 'uwbShortCode',
          label: $i18n.t('keyInventory.uwbShortCode'),
          minWidth: 160,
          showOverflowTooltip: true
        },
        {
          prop: 'vinCode',
          label: $i18n.t('keyInventory.vinCode'),
          minWidth: 140,
          showOverflowTooltip: true
        },
        {
          prop: 'keyCode',
          label: $i18n.t('keyInventory.keyCode'),
          minWidth: 160,
          showOverflowTooltip: true
        },
        {
          prop: 'carInfo',
          label: $i18n.t('keyInventory.carInfo'),
          minWidth: 160,
          showOverflowTooltip: true
        },
        {
          prop: 'type',
          label: $i18n.t('keyInventory.existCabinetType'),
          minWidth: 140,
          showOverflowTooltip: true,
          render: (h, scope) => {
            if (scope.row.type == 1) {
              return <span>在柜</span>
            } else if (scope.row.type == 2) {
              return <span>不在柜</span>
            } else {
              return <span>-</span>
            }
          }
        },
        {
          prop: 'operatorName',
          label: $i18n.t('keyInventory.operatorName'),
          minWidth: 140,
          showOverflowTooltip: true
        },
        {
          prop: 'operatorTime',
          label: $i18n.t('keyInventory.operatorTime'),
          minWidth: 220,
          showOverflowTooltip: true
        },
        {
          prop: 'cabinetSite',
          label: $i18n.t('keyInventory.cabinetSite'),
          minWidth: 160,
          showOverflowTooltip: true,
          render: (h, scope) => {
            if (scope.row.type == 1) {
              return <span>{scope.row.cabinetSite}</span>
            } else {
              return <span>-</span>
            }
          }
        },
        {
          prop: 'cabinetName',
          label: $i18n.t('keyInventory.cabinetName'),
          minWidth: 160,
          showOverflowTooltip: true,
          render: (h, scope) => {
            if (scope.row.type == 1) {
              return <span>{scope.row.cabinetName}</span>
            } else {
              return <span>-</span>
            }
          }
        },
        {
          prop: 'boxName',
          label: $i18n.t('keyInventory.boxName'),
          minWidth: 160,
          showOverflowTooltip: true,
          render: (h, scope) => {
            if (scope.row.type == 1) {
              return <span>{scope.row.boxName}</span>
            } else {
              return <span>-</span>
            }
          }
        }
      ]
    }
  },
  computed: {},
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (row.iddss === 1) {
        return 'warning-row'
      } else {
        return 'success-row'
      }
    },
    // 表格顶部按钮操作事件
    handleOperateEvent(data) {
      this.title = data.name
      const fnc = {
        export: () => {
          this.$confirm($i18n.t('keyInventory.prompt1'), $i18n.t('common.tip'), {
            confirmButtonText: $i18n.t('common.ok'),
            cancelButtonText: $i18n.t('common.cancel'),
            type: 'warning'
          }).then(() => {
            const params = { cabinetType: 2, ...this.getSearchParams() }
            exportExcel(exportUrl, params)
          })
        }
      }
      fnc[data.handleName]()
    },
    getSearchParams() {
      let formData = this.$refs?.eleTable?.$refs?.eleFormSearch.formData || {}
      // formData = this.getArrtoMap(formData)
      return formData
    },
    // 刷新表格数据
    refresh(isReset = true) {
      this.$refs.eleTable.refresh(isReset)
    }
  }
}
</script>
<style scoped lang="scss">
.mesProcess {
  /deep/.el-transfer-panel {
    width: 40% !important;
  }
  .warning-row {
    background: oldlace;
  }
}
</style>
